<html>
	<head>
		<title>登录</title>
		<link rel="stylesheet" href="bootstrap.min.css"/>
		<style type="text/css">
			body {
                 margin-left: auto;	
                 margin-right: auto;
	             margin-TOP: 100PX;
	             width: 20em;
	        }
	  </style>

	</head>
	<body>
		<!--下面是用户名输入框-->
		<form method="post">
		<div class="input-group">
			<span class="input-group-addon" id="basic-addon1">@</span>
			<input id="userName" type="text" name="name" class="form-control" placeholder="用户名" aria-describedby="basic-addon1">
		</div>
		<br>
		<!--下面是密码输入框-->
		<div class="input-group">
			<span class="input-group-addon" id="basic-addon1">@</span>
			<input id="passWord" type="password" name="pasword" class="form-control" placeholder="密码" aria-describedby="basic-addon1">
		</div>
		<br>
		<!--下面是登陆按钮,包括颜色控制-->
		<button type="submit" style="width:280px;" class="btn btn-default">登 录</button>
		</form>
	</body>
</html>
<?php 
$name=$_POST["name"];
$pasword=$_POST["pasword"];
if($name && $pasword){
	//通过PDO连接MYSQL
    $db = new PDO("mysql:host=127.0.0.1;dbname=scholl;charset=utf8","root","123456");
	$sql="select count(*) from stu where name=:name and pasword=:pasword";
	$sth=$db->prepare($sql);
	$sth->bindParam(':name', $name, PDO::PARAM_STR);
	$pasword=md5($pasword);
	$sth->bindParam(':pasword', $pasword, PDO::PARAM_STR);
	$ret=$sth->execute();
	$arr=$sth->fetchAll(PDO::FETCH_NUM);
	if($arr[0][0]==1){
		session_start();
		$_SESSION["name"]=$name;
		echo "登陆成功";
		header("Location:ingfo.php");
	}else{
		echo "用户名或密码不正确";
	}
}
?>